package com.umakr.ax.app.web;

import com.umakr.ax.app.service.InteractiveLotteryWebServices;
import com.umakr.ax.common.model.InteractiveLottery;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * 互动用户抽奖功能
 * @author umakr on 2018/5/5.
 */
@Controller
@RequestMapping("/api/web/interactiveLottery")
public class InteractiveLotteryController extends AbstractController {
    @Autowired
    InteractiveLotteryWebServices interactiveLotteryWebServices;

    @ApiOperation(value = "抽奖活动列表")
    @GetMapping(value = "/listLotteryHistory")
    @ResponseBody
    public Object listLotteryHistory(ModelMap modelMap, @RequestParam Long rsId,String searchText) {
        return setSuccessModelMap(modelMap, interactiveLotteryWebServices.listLotteryHistory(rsId,searchText));
    }

    @ApiOperation(value = "新增或修改抽奖活动")
    @PostMapping("/saveOrUpdateLottery")
    @ResponseBody
    public Object saveOrUpdateLottery(ModelMap modelMap,InteractiveLottery interactiveLottery) {
        return setSuccessModelMap(modelMap,interactiveLotteryWebServices.saveOrUpdateLottery(interactiveLottery));
    }

    @ApiOperation(value = "删除抽奖活动")
    @GetMapping(value = "/deleteLottery")
    @ResponseBody
    public Object deleteLottery(ModelMap modelMap,  @RequestParam Long lotteryId) {
        return setSuccessModelMap(modelMap,interactiveLotteryWebServices.deleteLottery(lotteryId));
    }

    @ApiOperation(value = "根据id获取抽奖活动信息")
    @GetMapping("/getLotteryInfoById")
    public Object getLotteryInfoById(ModelMap modelMap,@RequestParam(name = "lotteryId") Long lotteryId) {
        return setSuccessModelMap(modelMap,interactiveLotteryWebServices.getLotteryInfoById(lotteryId));
    }

}
